//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   PACKAGE : dcf
//   FILE    : SubscriberMessage.java
//   CLASS   : SubscriberMessage
//   DATE    : 2006-04-01
//   
//   DESCRIPTION
//   The SubscriberMessage is the message sent from the LocatorService to a publisher of a service that 
//   identifies the subscriber that desires use of the service.
//   
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   Copyright (c) 2006 by Hal Smith
//
//   Permission is hereby granted, free of charge, to any person obtaining a copy of this source code 
//   (the "Code")to deal with the Code without restriction, including without limitation the rights to use, copy,
//   modify, merge, publish and distribute the Code, and to permit persons to whom the Code is furnished to do 
//   so, subject to the following conditions:
//
//   The above copyright notice and this permission notice shall be included in all copies or substantial 
//   portions of the Software.
//   
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   VERSION HISTORY
//
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package dcf;


class SubscriberMessage extends Message {
	
	// The subscriber that desires the service.
	//
	private Subscriber subscriber;

	
	// Constructor. 
	//
	// This operation initializes the SubscriberMessage with the subscriber to be added to the publisher's list
	// of service users. If the supplied subscriber is null the operation will log an error and throw an 
	// InitializationException. There are no exceptions thrown by this operation.
	//
	public SubscriberMessage(Subscriber initSubscriber) throws InitializationException {
		
		// If either of the supplied parameter us null, log an error and throw an InitializationException.
		// Otherwise, save off the necessary data locally.
		//
		if (initSubscriber == null) {
			
			System.out.println("DisconnectMessage.DisconnectMessage(initEndpoint, initServiceName):");
			System.out.println("   Subscribers supplied cannot be null.");	
			
			throw new InitializationException();
			
		} else {
			
			subscriber = initSubscriber;
			
		}

	} // constructor

	
	// This operaiton returns the subscriber to be added to the publisher's list of list of service users. There
	// are no exceptions thrown by this operation.
	//
	public Subscriber getSubscriber() {
		
		return subscriber;
	
	} // getSubscriber()

	
	// This operation returns the service to which the enclosed subscriber wants to be 
	// subscribed. There are no exceptions thrown by this operation.
	//
	public String getServiceName() {
	
		return subscriber.getServiceName();
	
	} // getServiceName()

} // SubscriberMessage
